home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
017
/
bat203.lbr
/
batdem.bat
< prev
next >
Wrap
DOS Batch File
|
2011-02-01
|
4KB
|
116 lines
bat * Begin Extended Batch Demo *
bat * Standary DOS commands can be intermixed freely with BAT commands.
bat * Like basic, putting things at top is quicker for goto's / loops to find.
bat * Up to 15 chars are allowed for labels, contents of vars, and literals
bat * Ten variables are provided & may be passed to/from DOS. They're %0 to %9.
bat * The variable %R is a return code that any routine can set at 0000:04FE
bat * Note that 'begtype' does not do variable substitution, and all others do.
bat * Spaces are needed to delimit operators.
bat * Non-spaces will concatenate variables and literals.
bat * STATEOF sets return code based on state of files existance. See example.
bat cls
bat type type your first name and press enter.
bat read %8
bat %7 = 94 | * (don't look!)
bat goto -top
bat * number guessing demo *
bat -i.can.count %6 = 5
bat type i am thinking of a two digit number, can you guess it?
bat -c.loop read %5
bat if %5 = %7 skip 6
bat %6 = %6 - 1
bat if %6 <> 0 skip 2
bat type boo hisss! the number was %7 (press enter)
bat skip 3
bat type oh so close! you get %6 more tries.
bat goto -c.loop
bat type great! i was afraid you weren't going to get it! (press enter)
bat read
bat -top cls
bat type ======== %8's extended batch sampler menu ===========
bat begtype
C - I can Count
D - Directory of available programs
F - Testing for files
S - String operations
X - Exit
Select an option and press ENTER.
end
bat -entry read %9
bat %7 = %7 + 1
bat * Skiping is quicker than goto's, but only goes forward.
bat if %9 <> d skip 18
bat type enter file.spec for files you would like to see, or press ENTER for all.
bat read %1
bat if .%1 = . %1 = *.*
bat -dirques type would you like a (s)tandard or (w)ide directory?
bat read %2
bat * Notice you can chain togeather if's, like . . .
bat if %2 <> s if %2 <> w goto -dirques
bat %3 =
bat if %2 = w %3 = /w
bat cls
dir %1 %3 (notice that two parms are passed to dos here. %%1 and %%3)
bat * Returning to Extended Batch demo *
bat begtype
Press ENTER to continue. . .
end
bat read
bat goto -top
bat if %9 <> x skip 3
bat type so long %8... hope you find this extended batch facility useful!
bat type p.s. for quickie help, just enter 'bat' from dos.
bat exit
bat if %9 = c goto -i.can.count
bat if %9 <> f skip 18
bat type enter a file name for me to serch for.
bat read %9
bat type scanning for file: %9 . . .
bat stateof %9 * this will set the return code up (%R)
bat if %r <> 0 skip 2
bat type the file does exist - exactly as typed.
bat skip 7
bat if %r <> 1 skip 2
bat type the file does not exist on any drive.
bat skip 5
bat if %r <> 9 skip 2
bat type the file name given is invalid.
bat skip 2
bat type the file does exist - but was found on the %r drive.
bat type to properly find this file, the complete filename would be %9
bat type (press enter)
bat read
bat goto -top
bat if %9 <> s skip 18
bat type enter 0 to 2 strings for me to check out. (Try one like: prog123)
bat read %1 %2 %3
bat if %1 = %2 type the strings are equal.
bat if %1 <> %2 type the strings are not equal.
bat * notice a '.' will make sure that null entries can be found
bat if .%3 <> . type you have entered more than 2 strings!
bat if .%1 = . type you haven't entered any strings!
bat if .%1 <> . type you have entered at least 1 string.
bat %3 = %2%3%1
bat type a new variable has been created from them containing: %3
bat * %1 = %1 + 1
bat * type the increment of the first string is: %1
bat * %1 = %1 - 1
bat * %1 = %1 - 1
bat * type the decrement of the first string is: %1
bat type (press enter)
bat read
bat goto -top
bat type
bat type you did not select a valid option. type c,d,f,s or x and press enter.
bat goto -entry